import { request } from 'ice';

// 获取所有设备信息
export async function getDevices () {
  return await request('/api/devices');
}

// 删除指定设备
export async function deleteDevice(id) {
  return await request({
    url: `/api/devices/${id}`,
    method: 'delete'
  })
}

// 更新指定设备
export async function updateDevice(id) {
  return await request({
    url: `/api/devices/${id}/apply`,
    method: 'post',
    data: {
      "method": "sync"
    }
  })
}

// 启动指定设备
export async function startDevice(id) {
  return await request({
    url: `/api/devices/${id}/apply/start`,
    method: 'post',
    data: {
      "method": "start"
    }
  })
}

// 停止指定设备
export async function stopDevice(id) {
  return await request({
    url: `/api/devices/${id}/apply/stop`,
    method: 'post',
    data: {
      "method": "stop"
    }
  })
}

// 创建隧道
export async function putTunnels(devices) {
  return await request({
    url: `/api/devices/apply/createTunnel`,
    method: 'post',
    data: {
      "method": "tunnels",
      "meta": {
        "pathLabels": []
      },
      "devices": devices
    }
  })
}